<template>
  <basic-container :btnFlag = true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <div class="card-body">
        <avue-crud :data="resultListData"
                   :option="tableoption"
                   :page="page"
                   :table-loading="tableLoading"
                   @size-change="sizeChange"
                   @current-change="currentChange"
                   @refresh-change="refreshChange"
                   @search-change="searchChange"
                   @search-reset="refreshChange"
                   class="menu-min-height">
          <template slot-scope="scope" slot="menu">
            <div class="menu-title" @click.stop="viewDetail(scope.row,scope.index)">
              <i class="iconfont iconalter icon-warning"></i>
              <p class="menu-title-text">发布</p>
            </div>
          </template>
        </avue-crud>
      </div>
      <detail-dialog :achievementId="achievementIdDD"
                     :pmuc="pmucDD"
                     :showDetailDialog.sync="showDetailDialog"
                     :key="achievementIdDD"></detail-dialog>
    </div>
  </basic-container>
</template>
<script>
  import {REVIEW_DIC,PROJECT_DIC} from '@/const/dict'
  import { toDoReviewList } from "@/api/review";
  export default {
    name: "resultReleaseList",
    data() {
      return {
        headerData:{
          title:'成果发布'
        },
        taskKey:'review_offline',//线下流程确认阶段
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        tableLoading:false,
        resultListData: [],
        tableoption: {
          page: true,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn:false,
          menuWidth:100,
          keyId: "id",
          column: [
            {
              label: "规划名称",
              prop: "achievementTitle",
              width:420,
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a style="cursor: pointer;" onclick="detailDialog(\'' + row.achievementId + '\'' + ',' + '\'' + row.pmuc + '\')">' + value + '</a>';
              },

            },
            {
              label: "规划名称",
              prop: "titleLike",
              cell: true,
              search:true,
              hide: true,
              formatter: function (row, value, label, column) {
                return '<a style="cursor: pointer;" onclick="detailDialog(\'' + row.achievementId + '\'' + ',' + '\'' + row.pmuc + '\')">' + value + '</a>';
              },

            },
            {
              label: "规划等级",
              prop: "planningRank",
              type: "select",
              width:100,
              dicData: PROJECT_DIC.PLANNING_RANK,
              cell: true,
//              search:true,

            },
            {
              label: "发布方式",
              prop: "releaseWay",
              type: "select",
              // dicData: REVIEW_DIC.releaseWayDIC,
              dicData: [
                {
                  label: '政府印发',
                  value: '0'
                },
                {
                  label: '发改委和有关部门联合印发',
                  value: '1'
                },
                {
                  label: '部门自行印发',
                  value: '2'
                },
              ],
              cell: true,
//              search:true
            },
            {
              label: "规划类型",
              prop: "category",
              type: "select",
              width:120,
              dicData: PROJECT_DIC.CATEGORY,
              cell: true
            },
          ]
        },
        achievementIdDD: null,
        pmucDD: null,
        showDetailDialog: null,
        titleLikes: '',

      };
    },
    created(){
      this.getResultList(this.page);
      window.detailDialog = this.detailDialog;
    },
    methods: {
      detailDialog(achievementId, pmuc) {
        this.achievementIdDD = Number(achievementId);
        this.pmucDD = pmuc;
        this.showDetailDialog = true;
      },
      getResultList(page,params){
        this.tableLoading = true;
        toDoReviewList(Object.assign({
          current: page.currentPage,
          size: page.pageSize,
          taskKey:this.taskKey,
        }, params)).then(response => {
          this.resultListData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false
        })
      },
      refreshChange(){
        this.getResultList(this.page)
      },
      // 搜索
      searchChange(params){
        this.page.currentPage = 1
        this.getResultList(this.page,this.dealSearchParam(params) )
      },
      // 处理搜索过滤
      dealSearchParam (params) {
        if (params.titleLike) {
          params.titleLike = params.titleLike;
        }else{
          params.titleLike="";
        }
        this.titleLikes=  params.titleLike;
        return params;
      },
      currentChange(currentPage) {
        let page = this.page;
        page.currentPage = currentPage;
        let params={titleLike: this.titleLikes};
        this.getResultList(page, params);
      },
      sizeChange(pageSize) {
        let page = this.page;
        page.pageSize = pageSize;
        let params={titleLike: this.titleLikes};
        this.getResultList(page, params);
      },
      // 详情
      viewDetail(row,index){
        let src = `/reviewDetail/detail/${row.reviewId}`;
        this.$router.push({
          path: src,
          query:{
            taskId:row.taskId,
            planningRank:row.planningRank,
            achievementId:row.achievementId,
          }
        })
      },
    }
  };
</script>

<style lang="scss" scoped>

</style>
